package com.heima.article.pojos;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;


import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.heima.model.common.serializer.LongToStringSerializer;
import lombok.Data;

/**
 * 文章偏好表
 *
 * @TableName ap_article_preference
 */
@TableName(value = "ap_article_preference")
@Data
public class ApArticlePreference implements Serializable {
    /**
     * 主键id
     */
    @TableId(type = IdType.ASSIGN_ID)
    @JsonSerialize(using = LongToStringSerializer.class)
    private Long id;

    /**
     * 用户id
     */
    private Integer userId;

    /**
     * 文章id
     */
    @JsonSerialize(using = LongToStringSerializer.class)
    private Long articleId;

    /**
     * 用户对这篇文章是否喜欢
     * 0喜欢 1不喜欢
     */
    private Short isIgnored;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        ApArticlePreference other = (ApArticlePreference) that;
        return (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
                && (this.getArticleId() == null ? other.getArticleId() == null : this.getArticleId().equals(other.getArticleId()))
                && (this.getIsIgnored() == null ? other.getIsIgnored() == null : this.getIsIgnored().equals(other.getIsIgnored()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
        result = prime * result + ((getArticleId() == null) ? 0 : getArticleId().hashCode());
        result = prime * result + ((getIsIgnored() == null) ? 0 : getIsIgnored().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", userId=").append(userId);
        sb.append(", articleId=").append(articleId);
        sb.append(", isIgnored=").append(isIgnored);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}